Step 1 - Create project with C++ application and print to debug console

In this step you first create a new Kanzi Studio project with C++ application, and then add the code to the C++ application to print Hello world! to the Kanzi debug console.

To create a project with C++ application and print to Kanzi debug console:

  1. In Kanzi Studio Quick Start window click New Project:
    1. Choose the name and location for your project.
      For example, name your project Hello world.
    2. Set the Template to Application.

    Kanzi creates a Kanzi Studio project in <KanziWorkspace>/Projects/<ProjectName>/Tool_project directory and the structure for the Visual Studio solution for your project in <KanziWorkspace>/Projects/<ProjectName>/Application:

  2. In Kanzi Studio select File > Export > Export KZB.
    Kanzi Studio creates the kzb file and configuration files from your Kanzi Studio project. Kanzi Studio stores the exported files in <KanziWorkspace>/Projects/<ProjectName>/Application/bin or the location you specify in the Binary Export Directory property in Project > Properties. The kzb file contains all nodes and resources from your Kanzi Studio project, except the resources you mark in a localization table as locale packs.
    When you run your Kanzi application from Visual Studio, your Visual Studio solution reads these files to create your Kanzi application.
  3. In Visual Studio open the Visual Studio solution for your application located in Application/configs/platforms/win32.
    For example, if you named your Kanzi Studio project Hello world, the Visual Studio solution is called Hello_world.sln.
    TIP

    To open the directory of a Kanzi Studio project from Kanzi Studio, select File > Open in Windows Explorer.

  4. In Visual Studio in the Solution Explorer right-click the Hello_world project and select Set as StartUp Project.
  5. In Visual Studio open the hello_world.cpp file.
    Your application class uses the ExampleApplication class which simplifies application development by handling the registration of the required modules.
    #include <kanzi/kanzi.hpp>
    
    using namespace kanzi;
    
    class HelloWorld : public ExampleApplication
    
  6. Include the log.hpp header file to use the logger to print to the Kanzi debug console:
    #include <kanzi/core/log/log.hpp>
  7. When you place a function inside the onProjectLoaded()Kanzi calls the function after it loads your application.
    virtual void onProjectLoaded() KZ_OVERRIDE
    {
        // Prints Hello world! to the Kanzi debug console.
        kzLogInfo(KZ_LOG_CATEGORY_GENERIC, ("Hello world!"));
    }
  8. In Visual Studio select one of the solution configurations for your version of Visual Studio and run your application.
    For example, if you are still developing your application, select the GL_vs2015_Debug configuration. If you want to create a production version of your Kanzi application, select one of the available release configurations.

    Function kzLogInfo prints Hello world! to the Kanzi debug console.

    When in the debug mode, along with the Kanzi debug console, your Kanzi application is shown in the Kanzi player. Since by default a new Kanzi Studio project contains only a scene with a camera and a directional light, your application, shows an empty scene.

This is what your hello_world.cpp looks like when you complete this step.

#include <kanzi/kanzi.hpp>
#include <kanzi/core/log/log.hpp>


using namespace kanzi;

class HelloWorld : public ExampleApplication
{
public:

    virtual void onConfigure(ApplicationProperties& configuration) KZ_OVERRIDE
    {
        configuration.binaryName = "hello_world.kzb.cfg";
    }

    virtual void onProjectLoaded() KZ_OVERRIDE
    {
        // Project file was loaded from a kzb file.
        kzLogInfo(KZ_LOG_CATEGORY_GENERIC, ("Hello world!"));
        // Add initialization code here.
    }
};

Application* createApplication()
{
    return new HelloWorld;
}

< INTRODUCTION
NEXT STEP >

See also

API reference